/**
 * @Author: Jackey 327156719@qq.com
 * @Date: 2024-11-12 19:03:52
 * @LastEditors: Jackey 327156719@qq.com
 * @LastEditTime: 2024-11-12 19:06:33
 * @FilePath: src/main/java/org/springblade/common/config/ThreadPoolConfig.java
 * @Description: 这是默认设置,可以在设置》工具》File Description中进行配置
 */
package org.springblade.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.ThreadPoolExecutor;

@Configuration
public class ThreadPoolConfig {

    @Bean
    public AsyncTaskExecutor asyncTaskExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(5);
        executor.setMaxPoolSize(10);
        executor.setQueueCapacity(25);
        executor.setThreadNamePrefix("oss-callback-");
        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
        executor.initialize();
        return executor;
    }
}
